<template>
    <view class="container">
      <view>uni WebSocket && GatewayWorker基于Workerman开发的一个项目框架，用于快速开发TCP长连接应用</view>
      <view>H5版 & 微信小程序版</view>
    </view>
</template>

<script lang="ts" setup>

const url = 'ws://127.0.0.1:7272/socket.io';

uni.connectSocket({
	url,
	header: {
		'content-type': 'application/json'
	},
	method: 'GET'
});

uni.onSocketOpen(function (res) {
    console.log(res);
    console.log('WebSocket连接已打开！');
    uni.sendSocketMessage({
      data: 'xxxxxxxxx'
    });
});

uni.onSocketError(function (res) {
  console.log('WebSocket连接打开失败，请检查！');
});
</script>

<style scoped lang="scss">
.container {
  padding: 20rpx;
}
</style>